package com.wpx.log.core.handler;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import com.wpx.log.core.LogContext;
import com.wpx.log.core.LogRequestContext;
import com.wpx.log.core.annotation.OpLog;

public class OpNameLogHandler implements ILogHandler {

	@Override
	public Object handler(LogContext logContext, LogRequestContext logRequestContext,Field logField) {
		String opName = null;
		
		OpLog opLogAnnotation = logRequestContext.getOpLogAnnotationAsTarget();
		if(opLogAnnotation != null) {
			opName = opLogAnnotation.value();
		}
		
		opLogAnnotation = logRequestContext.getOpLogAnnotationAsMethod();
		
		opName = opName==null?opLogAnnotation.value(): (opName.concat("-").concat(opLogAnnotation.value()));
		
		return opName;
	}

}
